package com.jstide.credit.data.service.biz;

import cn.hutool.core.util.StrUtil;
import cn.hutool.db.Entity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.Optional;

public class FactorHelper {

    private static final Logger logger = LoggerFactory.getLogger(FactorHelper.class);

    private static int calculateTotal(long total ,int defaultScore) {
        return total>0? defaultScore:0;
    }

    public  static int translateTotal(String name,  int defaultScore , List<Entity> rs) {
        int result =0;
        try {
            long total =0;
            if(null!=rs && rs.size()>0){
                total =  Optional.ofNullable(rs.get(0).getLong("TOTAL")).orElse(0L);
            }
            result =  calculateTotal(total,defaultScore);
        }
        catch (Exception e){
            logger.error(StrUtil.format("项目{}计算错误：",name),e);
        }
        return result;
    }

}
